<template>
  <div class="detail">
    <van-nav-bar
      title="文章详情"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    >
      <template #title>
        <span class="title">文章搜索</span>
      </template>
      <template #left class="left">
        <van-icon class="icon" name="down" />
      </template>
    </van-nav-bar>
    <div class="subject">
      <div class="top">
        <h2>复盘日志(W12)</h2>
      </div>
      <div class="left">
        <img
          @click="$router.push('/home/myInfo?id=') + userInfo.id"
          v-if="userInfo.photo"
          :src="userInfo.photo"
          mode=""
        />
        <img
          @click="$router.push('/home/myInfo?id=') + userInfo.id"
          v-else
          src="@/assets/logo.png"
          mode=""
        />
        <div class="txt">
          <div class="name">翔爷</div>
          <div class="identity">2018/11/29 15:51:34</div>
        </div>
        <div v-if="attention" class="right" @click="attentions">
          <span>已关注</span>
        </div>
        <div v-else class="right" @click="attentions">
          <span>关注</span>
        </div>
      </div>
      <!-- 底侧点赞部分 -->
      <van-goods-action>
        <div class="text">
          <span>我有意见....</span>
        </div>
        <van-goods-action-icon icon="chat-o" text="客服" @click="onClickIcon" />
        <van-goods-action-icon
          icon="cart-o"
          text="购物车"
          @click="onClickIcon"
        />
        <van-goods-action-icon icon="shop-o" text="店铺" @click="onClickIcon" />
      </van-goods-action>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      userInfo: '',
      attention: true // 是否关注了
    }
  },
  methods: {
    // 点击左侧返回按钮触发事件
    onClickLeft () {
      alert('返回')
    },
    // 点击关注
    attentions () {
      this.attention = !this.attention
    }
  }
}
</script>

<style lang="less" scoped>
.detail {
  .van-nav-bar {
    background-color: rgb(164, 70, 192);
    .title {
      color: aliceblue;
    }
    .icon {
      transform: rotate(90deg);
      font-size: 25px;
      color: aliceblue;
    }
  }
  .subject {
    padding: 0 10px;
    .top {
      padding: 10px 0 0 15px;
    }
    .left {
      display: flex;
      justify-content: center;
      align-items: center;
      flex: 1;
      margin-top: 30px;
      img {
        width: 50px;
        height: 50px;
        border-radius: 25px;
        margin-left: 15px;
      }
      .txt {
        flex: 1;
        font-size: 14px;
        margin-left: 10px;
        .name {
          font-size: 12px;
        }
        .identity {
          color: @color;
          border-radius: 10px;
          color: rgb(175, 175, 168);
          font-size: 4px;
        }
      }
      .right {
        background-color: blueviolet;
        border-radius: 20px;
        width: 80px;
        height: 26px;
        text-align: center;
        line-height: 26px;
        color: #fff;
        font-size: 12px;
        margin-right: 10px;
      }
    }
    .van-goods-action {
      .text {
        flex: 1;
        margin-left: 20px;
        width: 120px;
        height: 30px;
        border: 2px solid rgb(158, 143, 143);
        border-radius: 10px;
        span {
          margin-left: 15px;
          font-size: 14px;
          line-height: 30px;
          color: rgb(165, 171, 172);
        }
      }
    }
  }
}
</style>
